package com.sloera.spring.tx.xml;

/**
 * @author sloera
 * @create 2020/4/12
 */
public class BookShopSserviceImpl implements BookShopSservice {
    private BookShopDao bookShopDao;

    public void setBookShopDao(BookShopDao bookShopDao) {
        this.bookShopDao = bookShopDao;
    }

    @Override
    public void purchase(String username, String isbn) {
        //获取书的单价
        int bookPriceByIsbn = bookShopDao.findBookPriceByIsbn(isbn);
        //更新书的库存
        bookShopDao.updateBookStock(isbn);
        //更新用户余额
        bookShopDao.updateUserAccount(username, bookPriceByIsbn);
    }
}
